#!/bin/bash

for i in `ls src`
do
	# remove trailing whitespace
	sed -i 's/[ \t]*$//' "src/$i"

	# replace \t with four whitespaces
	sed -i 's/\t/    /g' "src/$i"

	# remove last blank line
	while :
	do
		old_filesize=`stat -c '%s' src/$i`
		sed -i '${/^$/d}' "src/$i"
		new_filesize=`stat -c '%s' src/$i`

		if [[ $new_filesize -eq $old_filesize ]] 
		then
			break
		fi
	done
done
